<?php

if (! defined('BASEPATH')) {
	exit('Access Denied');
}
class M_templets_cache extends CI_Model {
	private $db ;
	private $table_pre ; //数据表表的前缀
	function M_templets_cache(){
		
		date_default_timezone_set('Asia/Shanghai');
		parent::__construct();
		$this->db = $this->load->database('real_data',true);
		$this->table_pre = $this->db->table_pre ;
	}
	//插入一条数据
	function insert_one($table,$data){
		$this->db->insert($table,$data) ;
		return array(
			'affect_num'=>$this->db->affected_rows() ,
			'insert_id'=>$this->db->insert_id(),
			'sql'=>$this->db->last_query()
		);
		
	}	
	//查询1条数据，返回结果
	function query_one($sql){
		return $this->db->query($sql)->row_array();		
	}
//修改数据
	function update_data($sql){
	
		$query = $this->db->query($sql);
		return $this->db->affected_rows(); //返回影响的行数
	}
	
	
	
}